<template>
	<view class="content">
		<u-navbar title="退款订单" :placeholder='true' height="88rpx" leftIconColor="#fff"
			titleStyle='color:#fff;font-size:32rpx' left-icon-size="32rpx" bg-color="#FF594D" :autoBack="true">
		</u-navbar>

		<view class="search_content">
			<search-button-input @getValue="getSearch"></search-button-input>
		</view>
		<view class="order_content">
			<template v-for="(item,index) in  refundData">
				<view class="order_item" :key="index">
					<view class="" @click="navigateTo('/pages_mine/pages/refund-detail/refund-detail?id='+item.id)">
						<view class="order_status">
							<view class="order_num">
								订单编号：{{item.number}}
							</view>
							<view class="status">
								{{getStatusText(item.status)}}
							</view>
						</view>
						<view class="line">
							<u-line></u-line>
						</view>
						<view class="order_goods_content">
							<template v-for="(item1,index1) in item.orderDetails">
								<view class="order_goods" :key="index1">
									<goods-num :item='item1'>
									</goods-num>
								</view>
							</template>
						</view>
						<view class="line">
							<u-line></u-line>
						</view>
					</view>
					<view class="operation">
						<view class="operation_money">
							已付款：<text>￥{{item.amount}}</text>
						</view>
					</view>
				</view>
			</template>
		</view>
	</view>
</template>

<script>
	import {
		ordersList
	} from '../../../api/employee.js'
	export default {
		onShow() {
			this.getOrdersList()
		},
		data() {
			return {
				titleStyle: {
					color: '#fff'
				},
				delModel_show: false,
				refundList: [],
				refundData: []
			}
		},
		created() {},
		watch: {
			refundData(newValue) {
				if (newValue.length == 0) {
					uni.showToast({
						title: '无订单',
						icon: 'error'
					})
				}
			}
		},
		methods: {
			tabClick(item) {
				console.log(item);
			},
			navigateTo(url) {
				uni.redirectTo({
					url
				})
			},
			getSearch(value) {
				// console.log(value);
				this.phone = value
				if (value.length < 11 || !Boolean(value - 0)) {
					if (value.length === 0) {
						this.refundData = this.refundList
						return
					}
					uni.showToast({
						title: '输入正确手机号',
						icon: 'error'
					})
					return
				}
				this.refundData = this.refundList.filter(item => {
					if (item.phone == this.phone) {
						// console.log(item);
						return item
					}
				})

			},
			async getOrdersList() {
				const res = await ordersList()
				console.log(res);
				this.refundList = res.rows.filter(item => item.status == 7)
				this.refundData = res.rows.filter(item => item.status == 7)
				// console.log(this.refundList);
			},
			getStatusText(status) {
				switch (status) {
					case 1:
					case 2:
						return '待付款'
					case 3:
						return '待发货'
					case 4:
						return '已发货'
					case 5:
						return '已完成'
					case 6:
						return '已取消'
					case 7:
						return '退款中'
					case 8:
						return '管理员同意退款'
					case 9:
						return '待拼单'
					case 10:
						return '待取货'
				}
			},
		}
	}
</script>

<style lang="scss">
	.content {
		background-color: #f3f3f3;
		min-height: 100vh;


		// padding-top: 35rpx;
		.tab {
			background-color: #fff;
			margin-bottom: 20rpx;
		}

		.order_content {
			padding-top: 20rpx;

			.order_item {
				padding: 25rpx 20rpx 24rpx 40rpx;
				background-color: #fff;
				margin-bottom: 20rpx;
				border-radius: 20rpx 20rpx 20rpx 20rpx;

				.order_status {
					display: flex;
					justify-content: space-between;

					.order_num {
						font-size: 24rpx;
						font-family: PingFang SC, PingFang SC;
						font-weight: 500;
						color: #777777;

					}

					.status {
						font-size: 26rpx;
						font-family: PingFang SC, PingFang SC;
						font-weight: 800;
						color: #FF2525;
					}
				}

				.line {
					padding: 20rpx 0;
				}

				.order_goods_content {
					.order_goods {
						margin-bottom: 20rpx;

						&:last-of-type {
							margin-bottom: 0rpx;

						}
					}
				}

				.operation {
					display: flex;
					justify-content: space-between;
					align-items: center;

					.operation_money {
						font-size: 24rpx;
						font-weight: 500;
						color: #777777;

						text {
							font-size: 32rpx;
							font-family: PingFang SC, PingFang SC;
							font-weight: 800;
							color: #FF2525;
						}
					}

					.operation_right_content {
						display: flex;
						justify-content: center;

						.btn {
							width: 170rpx;
							height: 56rpx;
							line-height: 56rpx;
							text-align: center;
							box-sizing: border-box;
							border-radius: 10rpx 10rpx 10rpx 10rpx;
						}

						.operation_left {
							border: 1rpx solid #FF594D;
							color: #FF594D;
						}

						.operation_right {
							margin-left: 37rpx;
							background: #FF594D;
							color: #FFFFFF;
						}
					}
				}
			}
		}

		.delModel {
			width: 656rpx;
			height: 339rpx;
			box-sizing: border-box;
			padding: 24rpx 20rpx;

			.delTitle {
				font-size: 32rpx;
				font-family: PingFang SC, PingFang SC;
				font-weight: 500;
				color: #333332;
				display: flex;
				justify-content: space-between;

				image {
					width: 32rpx;
					height: 32rpx;
				}
			}

			.delText {
				height: 170rpx;
				text-align: center;
				line-height: 170rpx;
			}



			.operation {
				display: flex;
				justify-content: center;


				.btn {
					width: 170rpx;
					height: 56rpx;
					line-height: 56rpx;
					text-align: center;
					box-sizing: border-box;
					border-radius: 10rpx 10rpx 10rpx 10rpx;
				}

				.operation_left {
					border: 1rpx solid #FF594D;
					color: #FF594D;
					margin-right: 37rpx;

					.operation_money {
						font-size: 24rpx;
						font-weight: 500;
						color: #777777;

						text {
							font-size: 32rpx;
							font-family: PingFang SC, PingFang SC;
							font-weight: 800;
							color: #FF2525;
						}
					}
				}

				.operation_right {
					background: #FF594D;
					color: #FFFFFF;
				}
			}
		}

	}
</style>